import { defineStore } from "pinia";
import { MessageUser } from "~~/types";

interface messageUserStoreInterface {
  messageUserList: MessageUser[];
}

export const useMessageUserList = defineStore("messageUser", {
  state: (): messageUserStoreInterface => {
    return {
      messageUserList: [],
    };
  },
  getters: {
    getUserList: (state) => state.messageUserList,
  },
  actions: {
    setUserList(list: MessageUser[]) {
      this.messageUserList = list;
    },
    setUserListItem(value: MessageUser) {
      this.messageUserList.unshift(value);
    },
  },
});
